package com.atguigu.springcloud.controller;

import com.atgui.springcloud.base.CommonResult;
import com.atgui.springcloud.request.UserParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("/consumer")
public class OrderController {


//    private static final String BASE_URL = "http://127.0.0.1:8001/api";
    // 使用Eureka注册中心注册的服务名进行调用
    private static final String BASE_URL = "http://cloud-payment-service/api";
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/get/{serial}")
    public Object getOne(@PathVariable("serial") String serial){
        String url = BASE_URL+"/payment/discovery";

        CommonResult result = restTemplate.getForObject(url,CommonResult.class);

        return result;
    }
}
